package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.rpc.finance.dto.onaccount.OnAccountDetailDTO;
import com.ctshk.rpc.finance.dto.onaccount.QueryQuotaDTO;
import com.ctshk.rpc.finance.req.onaccount.OnAccountDetailReq;
import com.ctshk.rpc.finance.req.onaccount.QueryQuotaReq;
import com.ctshk.rpc.finance.req.onaccount.UseQuotaReq;
import com.ctshk.rpc.finance.service.IFinanceOnAccountCurrencyQuotaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 财务挂账币种额度 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-03-30
 */
@RestController
@Api(value = "挂账额度", tags = "挂账额度")
@RequestMapping("/finance-on-account-currency-quota")
public class FinanceOnAccountCurrencyQuotaController extends BaseController {

    @DubboReference
    private IFinanceOnAccountCurrencyQuotaService onAccountCurrencyQuotaService;

    @ApiOperation(value = "查询额度", notes = "查询额度（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "挂账额度-查询额度", operDesc = "挂账额度-查询额度")
    @PostMapping("/query-quota")
    public Result<QueryQuotaDTO> queryQuota(@RequestBody @Valid QueryQuotaReq req) {
        return onAccountCurrencyQuotaService.queryQuota(req);
    }

    @ApiOperation(value = "使用额度", notes = "使用额度（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "挂账额度-使用额度", operDesc = "挂账额度-使用额度")
    @PostMapping("/use-quota")
    public Result useQuota(@RequestBody @Valid List<UseQuotaReq> reqList) {
        return onAccountCurrencyQuotaService.useQuota(reqList);
    }

}
